package com.ms.dsq_english.adapter

import android.annotation.SuppressLint
import android.content.Context
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.ms.dsq_english.R
import com.ms.dsq_english.model.StoreBean

class RVAdapterAreaCurrent(private val context: Context, private val list: ArrayList<StoreBean.DataBean.NewShopBean.ShopDetailsBean>) :
        RecyclerView.Adapter<RVAdapterAreaCurrent.ViewHolder>()
{
    class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView)
    {
        val tvDate: TextView = itemView.findViewById(R.id.item_rv_ac_tv_date)

        val tvArea: TextView = itemView.findViewById(R.id.item_rv_ac_tv_area)
        val tvPer: TextView = itemView.findViewById(R.id.item_rv_ac_tv_per)
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder
    {
        return ViewHolder(View.inflate(context, R.layout.item_rv_area_current, null))
    }

    @SuppressLint("SetTextI18n")
    override fun onBindViewHolder(holder: ViewHolder, position: Int)
    {
        val data = list[position % list.size]

        holder.tvDate.text = data.reg_times
        holder.tvArea.text = data.shop_name
        holder.tvPer.text =data.address
    }

    override fun getItemCount(): Int
    {
        return when
        {
            list.size == 0 -> 0
            list.size == 5 -> 5
            else -> Integer.MAX_VALUE
        }

//        return list.size
    }
}